home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / demos / spaceballscrktro / cracktro.asm < prev    next >
Encoding:
Assembly Source File  |  1980-01-04  |  11.5 KB  |  600 lines

  1.     ;Hellfire - Cracktro
  2.     ;
  3.     ;By Jobbo 03/07/95
  4.  
  5.     Section    MainCode,Code
  6.  
  7.     Incdir    Sources:Includes/
  8.     Include    Hardware.i
  9.     Include    StartUpOCS.i
  10.     Include    ProRunner.i
  11.     Incdir    Sources:Cracktro/
  12.  
  13.  
  14. Main    Move.l    #textBitmap,d0                    ;Set up text bpls
  15.     MoveQ    #2-1,d1
  16.     Move.w    #28,d2
  17.     Lea    bplPtrs+3*8,a0
  18.     Bsr    SetUpBplPtrs
  19.  
  20.     Bsr    ScreenDB                    ;Set up background bpls
  21.     Bsr    SetUpBGColour                    ;Set up copper background
  22.  
  23.     Move.l    #module,pr_module                ;Set up music replay
  24.     Move.w    #0,pr_startposition
  25.     Bsr    pr_init        
  26.  
  27.     Lea    CUSTOM,a6
  28.     Move.l    VBRReg(PC),a0
  29.     Lea    $6c(a0),a0
  30.     Move.l    #Level3,(a0)                    ;New Level3 handler
  31.     Move.w    #SETIT+DMAEN+BPLEN+COPEN+BLTPRI+BLTEN,DMACON(a6);DMA - ON
  32.     Move.w    #SETIT+INTEN+VERTB,INTENA(a6)            ;VBI interrupt - ON
  33.     Move.l    #copList,COP1LCH(a6)                ;Point copper at list
  34.     Move.l    #copCust,COP2LCH(a6)
  35.     Move.w    #0,COPJMP1(a6)                    ;Strobe to start
  36.  
  37.     Move.w    #2,fadeSpeed
  38.     MoveQ    #16*2-1,d0
  39. .forFadeIn
  40.     Move.w    d0,-(SP)
  41.     Bsr    VWait
  42.     Bsr    InsertPalette
  43.     Bsr    BlitTwirl
  44.     Bsr    ScreenDB
  45.     Bsr    FadeToPalette
  46.     ;Move.w    #$080,COLOR00(a6)
  47.     Move.w    (SP)+,d0
  48.     Dbf    d0,.forFadeIn
  49.  
  50. .mouseWait
  51.     Bsr    VWait
  52.     Bsr    BlitTwirl
  53.     Bsr    ScreenDB
  54.     ;Move.w    #$080,COLOR00(a6)
  55.     Btst    #6,CIAAPRA
  56.     Bne.s    .mouseWait
  57.  
  58.     Move.w    #-1,pr_musicfadedirection
  59.     Move.w    #-1,twirlCounter
  60.     Move.w    #-1,clearCounter
  61.     Move.w    #2,fadeSpeed
  62.     MoveQ    #16*2+16-1,d0
  63. .forFadeOut
  64.     Move.w    d0,-(SP)
  65.     Bsr    VWait
  66.     Bsr    InsertPalette
  67.     Bsr    BlitTwirl
  68.     Bsr    ScreenDB
  69.     Bsr    FadeToBlack
  70.     ;Move.w    #$080,COLOR00(a6)
  71.     Move.w    (SP)+,d0
  72.     Dbf    d0,.forFadeOut
  73.  
  74.     Bsr    pr_end
  75.     Move.w    #INTEN,INTENA(a6)                ;Stop Interrupts
  76.     Rts
  77.  
  78.  
  79. ;======================================================================================================
  80.  
  81.  
  82.     ;VBI Interrupt server, plays music. And if CustIntPtr is
  83.     ;non-zero then the subroutine it points to will be called.
  84.     ;
  85.     ;Restores all
  86.     ;---------------------------------------------------------
  87.  
  88. vTimer        Dc.l    0
  89. custIntPtr    Dc.l    TextWriter
  90.  
  91. Level3    MoveM.l    d0-a6,-(SP)
  92.  
  93.     Bsr    pr_music
  94.     
  95.     AddQ.b    #1,vBlank
  96.     AddQ.l    #1,vTimer
  97.  
  98.     Tst.l    custIntPtr
  99.     Beq.s    .nil
  100.     MoveM.l    d0-a6,-(SP)
  101.     Move.l    custIntPtr,a0
  102.     Jsr    (a0)
  103.     MoveM.l    (SP)+,d0-a6
  104. .nil    
  105.     Lea    CUSTOM,a6
  106.     Move.w    #VERTB,INTREQ(a6)                ;Clear interrupt request bit
  107.     MoveM.l    (SP)+,d0-a6
  108.     Rte
  109.  
  110.  
  111. ;------------------------------------------------------------------------------------------------------
  112.  
  113.  
  114.     ;Waits one vertical blank
  115.     ;
  116.     ;Corrupts: None
  117.     ;------------------------
  118.  
  119. vBlank    Dc.b    0
  120.     Even
  121.  
  122. VWait    Clr.b    vBlank
  123. .wait    Tst.b    vBlank
  124.     Beq.s    .wait
  125.     Rts
  126.  
  127. ;------------------------------------------------------------------------------------------------------
  128.  
  129.  
  130.     ;Set-up bitplane pointers in copper list.
  131.     ;
  132.     ;Corrupts: d0-d1
  133.     ;----------------------------------------
  134.     ;PRE: d0.l -> Start of bpl data
  135.     ;     d1.w =  Counter for no of bpls - 1
  136.     ;     d2.l =  Bytes between planes
  137.     ;     a0.l -> BplPtrs in copper list
  138.     
  139. SetUpBplPtrs
  140.     Move.w    d0,2(a0)                    ;High word of bpl pointer
  141.     Swap    d0
  142.     Move.w    d0,6(a0)                    ;Low word of bpl pointer
  143.     Swap    d0
  144.     Add.l    d2,d0                        ;Next bpl start
  145.     AddQ    #8,a0                        ;Next ptr in copper list
  146.     Dbf    d1,SetUpBplPtrs
  147.     Rts
  148.  
  149.  
  150. ;======================================================================================================
  151.  
  152.  
  153. SetUpBGColour
  154.     Lea    copCust,a0
  155.  
  156.     Move.l    #$2c57fffe,d4
  157.     Move.l    #$01800000,d5
  158.     Move.l    #$2cc7fffe,d6
  159.     Move.l    #$01800000,d7
  160.  
  161.     Move.l    d4,(a0)+
  162.     Move.l    d5,(a0)+
  163.     Move.l    d6,(a0)+
  164.     Move.l    d7,(a0)+
  165.     Add.l    #$01000000,d4
  166.     Add.l    #$01000000,d6
  167.  
  168.     Sub.l    #$00020000,d4
  169.     Move.w    #198-1,d3
  170. .forLns    Move.l    d4,(a0)+
  171.     Move.l    d5,(a0)+
  172.     Move.l    d6,(a0)+
  173.     Move.l    d7,(a0)+
  174.     Add.l    #$01000000,d4
  175.     Add.l    #$01000000,d6
  176.     Dbf    d3,.forLns
  177.  
  178.     Add.l    #$00020000,d4
  179.     Move.l    d4,(a0)+
  180.     Move.l    d5,(a0)+
  181.     Move.l    d6,(a0)+
  182.     Move.l    d7,(a0)+
  183.  
  184.     Move.l    #$fffffffe,(a0)    
  185.     Rts
  186.  
  187.  
  188. ;------------------------------------------------------------------------------------------------------
  189.  
  190.  
  191. InsertPalette
  192.     Lea    currentPalette,a0
  193.     Lea    colours+6,a1
  194.     Lea    copCust+6,a2
  195.     Move.w    (a0)+,d7
  196.     
  197.     MoveQ    #30-1,d0
  198. .forPal    Move.w    (a0)+,(a1)
  199.     AddQ    #4,a1
  200.     Dbf    d0,.forPal
  201.     Move.w    (a0)+,d6
  202.     Move.w    d6,(a1)
  203.     AddQ    #4,a1
  204.  
  205.     Move.w    d6,(a2)
  206.     Lea    16(a2),a2
  207.     Move.w    #198/9-1,d1
  208. .forLns    MoveQ    #9-1,d0
  209. .forMvs    Move.w    d7,(a2)
  210.     Lea    16(a2),a2
  211.     Dbf    d0,.forMvs
  212.     Dbf    d1,.forLns
  213.     Move.w    d6,(a2)
  214.  
  215.     Rts
  216.  
  217.  
  218. ;------------------------------------------------------------------------------------------------------
  219.  
  220.  
  221. fadeSpeed    Dc.w    0
  222. fadeCounter    Dc.w    0
  223.  
  224. FadeToPalette
  225.     AddQ.w    #1,fadeCounter
  226.     Move.w    fadeCounter(PC),d0
  227.     Cmp.w    fadeSpeed,d0
  228.     Blt.s    .exit
  229.     Move.w    #0,fadeCounter    
  230.     Lea    palette(PC),a0
  231.     Lea    currentPalette,a1
  232.     
  233.     MoveQ    #0,d3
  234.     MoveQ    #0,d4
  235.     MoveQ    #32-1,d0
  236. .forCuls
  237.     Move.w    (a0)+,d1
  238.     Move.w    (a1)+,d2
  239.     Cmp.w    d2,d1
  240.     Beq.s    .skip
  241.     
  242.     Move.w    d2,d7
  243.     Move.b    d1,d3
  244.     Move.b    d2,d4
  245.     Move.b    d1,d5
  246.     Move.b    d2,d6
  247.     Lsr.w    #8,d1
  248.     Lsr.w    #8,d2
  249.     And.b    #$f0,d3
  250.     And.b    #$f0,d4
  251.     And.b    #$0f,d5
  252.     And.b    #$0f,d6
  253.  
  254.     Cmp.b    d2,d1
  255.     Beq.s    .redOk
  256.     Bgt.s    .redBig
  257.     Sub.w    #$100,d7
  258.     Bra.s    .redOk
  259. .redBig    Add.w    #$100,d7
  260. .redOk    Cmp.w    d4,d3
  261.     Beq.s    .grnOk
  262.     Bgt.s    .grnBig
  263.     Sub.b    #$010,d7
  264.     Bra.s    .grnOk
  265. .grnBig    Add.b    #$010,d7
  266. .grnOk    Cmp.b    d6,d5
  267.     Beq.s    .bluOk
  268.     Bgt.s    .bluBig
  269.     SubQ    #$001,d7
  270.     Bra.s    .bluOk
  271. .bluBig    AddQ    #$001,d7
  272. .bluOk
  273.     Move.w    d7,-2(a1)
  274. .skip    Dbf    d0,.forCuls    
  275.  
  276. .exit    Rts
  277.  
  278.     ;----------------------------------------------------------------------------------------------
  279.  
  280. FadeToBlack
  281.     AddQ.w    #1,fadeCounter
  282.     Move.w    fadeCounter(PC),d0
  283.     Cmp.w    fadeSpeed,d0
  284.     Blt.s    .exit
  285.     Move.w    #0,fadeCounter
  286.     Lea    currentPalette,a1
  287.     
  288.     MoveQ    #32-1,d0
  289. .forCuls
  290.     Move.w    (a1)+,d1
  291.     Tst.w    d1
  292.     Beq.s    .skip
  293.     
  294.     Move.w    d1,d7
  295.     Move.b    d1,d2
  296.     Move.b    d1,d3
  297.     Lsr.w    #8,d1
  298.     And.b    #$f0,d2
  299.     And.b    #$0f,d3
  300.  
  301.     Tst.b    d1
  302.     Beq.s    .redOk
  303.     Sub.w    #$100,d7
  304. .redOk    Tst.b    d2
  305.     Beq.s    .grnOk
  306.     Sub.w    #$010,d7
  307. .grnOk    Tst.b    d3
  308.     Beq.s    .blueOk
  309.     SubQ    #$001,d7
  310. .blueOk
  311.     Move.w    d7,-2(a1)
  312. .skip    Dbf    d0,.forCuls    
  313.  
  314. .exit    Rts
  315.  
  316.  
  317. ;------------------------------------------------------------------------------------------------------
  318.  
  319.  
  320. TEXTSTARTOFFSET    Equ    28*7*2
  321. PAUSETIME    Equ    21*3+50*7
  322.  
  323. xOffset        Dc.w    0
  324. lineOffset    Dc.l    textBitmap+TEXTSTARTOFFSET
  325. charPtr        Dc.l    message
  326. clearCounter    Dc.w    32
  327. clearLineOffset    Dc.l    textBitmap+TEXTSTARTOFFSET
  328.  
  329.  
  330. TextWriter
  331.     Tst.w    clearCounter
  332.     Blt.s    .endClear
  333.     Beq.s    .nextChar
  334.     SubQ.w    #1,clearCounter
  335.     Cmp.w    #21*3,clearCounter
  336.     Bge.s    .paused
  337. .endClear
  338.     Move.l    clearLineOffset(PC),a0
  339.     Cmp.l    #textBitmap+TEXTSTARTOFFSET+28*3*2*21*3,a0        ;Ugh!
  340.     Bge.s    .paused
  341.     Add.l    #28*3*2,clearLineOffset
  342.     MoveQ    #3*2-1,d0
  343. .forLgs
  344.     REPT    7
  345.     Clr.l    (a0)+
  346.     ENDR
  347.     Dbf    d0,.forLgs
  348. .paused    Rts
  349.  
  350. .nextChar
  351.     Move.l    #textBitmap+TEXTSTARTOFFSET,clearLineOffset
  352.     Move.l    charPtr(PC),a0
  353.     AddQ.l    #1,charPtr
  354.     MoveQ    #0,d0
  355.     Move.b    (a0),d0
  356.     Bne.s    .notEOT
  357.     Clr.w    xOffset                            ;End of Text
  358.     Move.l    #textBitmap+TEXTSTARTOFFSET,lineOffset
  359.     Move.l    #message,charPtr
  360.     Move.w    #PAUSETIME,clearCounter
  361.     Move.l    #textBitmap+TEXTSTARTOFFSET,clearLineOffset
  362.     Rts
  363. .notEOT    Cmp.b    #1,d0
  364.     Bne.s    .notEOL
  365.     Clr.w    xOffset                            ;End of Line
  366.     Add.l    #28*9*2,lineOffset
  367.     Bra.s    .nextChar
  368. .notEOL    Cmp.b    #2,d0
  369.     Bne.s    .notEOP
  370.     Clr.w    xOffset                            ;End of Page
  371.     Move.l    #textBitmap+TEXTSTARTOFFSET,lineOffset
  372.     Move.w    #PAUSETIME,clearCounter
  373.     Move.l    #textBitmap+TEXTSTARTOFFSET,clearLineOffset
  374.     Rts
  375. .notEOP    Cmp.b    #" ",d0                            ;Space char
  376.     Bne.s    .notSpace
  377.     AddQ.w    #1,xOffset
  378.     Bra    .nextChar
  379. .notSpace
  380.  
  381.     ;Draw Char
  382.  
  383.     Lea    font(PC),a0
  384.     Move.l    lineOffset(PC),a1
  385.     Add.w    xOffset(PC),a1
  386.     AddQ.w    #1,xOffset
  387.     Sub.w    #" ",d0
  388.     Mulu    #12*2*2,d0
  389.     Add.w    d0,a0
  390.     MoveQ    #12-1,d0
  391. .forLns    Move.l    (a0)+,d1
  392.     Move.l    d1,d2
  393.     Swap    d2
  394.     Or.w    d1,d2
  395.     Not.w    d2
  396.     Ror.w    #8,d2
  397.     Ror.w    #8,d1
  398.     And.b    d2,(a1)
  399.     Or.b    d1,(a1)
  400.     Rol.w    #8,d2
  401.     Rol.w    #8,d1
  402.     And.b    d2,1(a1)
  403.     Or.b    d1,1(a1)
  404.     Swap    d1
  405.     Ror.w    #8,d2
  406.     Ror.w    #8,d1
  407.     And.b    d2,28(a1)
  408.     Or.b    d1,28(a1)
  409.     Rol.w    #8,d2
  410.     Rol.w    #8,d1
  411.     And.b    d2,28+1(a1)
  412.     Or.b    d1,28+1(a1)
  413.     Lea    28*2(a1),a1
  414.     Dbf    d0,.forLns
  415.     Rts
  416.  
  417.     ;----------------------------------------------------------------------------------------------
  418.  
  419. message    Include    Text.Asm
  420.  
  421.  
  422. ;------------------------------------------------------------------------------------------------------
  423.  
  424.  
  425. bitmapSrcPtr    Dc.l    bitmap2
  426. bitmapDestPtr    Dc.l    bitmap1
  427.  
  428. ScreenDB
  429.     Move.l    bitmapDestPtr(PC),d0
  430.     Move.l    bitmapSrcPtr(PC),bitmapDestPtr
  431.     Move.l    d0,bitmapSrcPtr
  432.  
  433.     Move.l    bitmapSrcPtr(PC),d0
  434.     Add.l    #40*61*3+6,d0
  435.     MoveQ    #3-1,d1
  436.     MoveQ    #40,d2
  437.     Lea    bplPtrs,a0
  438.     Bsr    SetUpBplPtrs
  439.     Rts
  440.  
  441.  
  442. ;------------------------------------------------------------------------------------------------------
  443.  
  444.  
  445. twirlCounter    Dc.w    0
  446.  
  447.  
  448. BlitTwirl
  449.     Lea    blitVals+880*4,a0
  450.     Tst.w    twirlCounter
  451.     Blt    .twirl
  452.  
  453.     AddQ.w    #1,twirlCounter
  454.     Move.w    twirlCounter(PC),d0
  455.     Cmp.w    #$40,d0
  456.     Blt.s    .still
  457.     Lea    blitVals+880*0,a0
  458.     Cmp.w    #$100*1+$40*1,d0
  459.     Blt    .twirl
  460.     Lea    blitVals+880*1,a0
  461.     Cmp.w    #$100*2+$40*1,d0
  462.     Blt    .twirl
  463.     Cmp.w    #$100*2+$40*2,d0
  464.     Blt.s    .still
  465.     Lea    blitVals+880*2,a0
  466.     Cmp.w    #$80*1+$100*2+$40*2,d0
  467.     Blt    .twirl
  468.     Lea    blitVals+880*3,a0
  469.     Cmp.w    #$80*2+$100*2+$40*2-1,d0
  470.     Blt    .twirl
  471.     Clr.w    twirlCounter
  472.     Bra.s    .twirl
  473.  
  474. .still    Move.l    bitmapSrcPtr(PC),BLTAPTH(a6)
  475.     Move.l    bitmapDestPtr(PC),BLTDPTH(a6)
  476.     Move.l    #0,BLTAMOD(a6)
  477.     Move.l    #$ffffffff,BLTAFWM(a6)
  478.     Move.l    #$09f00000,BLTCON0(a6)
  479.     Move.w    #320*3<<6+20,BLTSIZE(a6)
  480. .bWait    Btst    #14,DMACONR(a6)
  481.     Bne.s    .bWait
  482.     Rts
  483.  
  484.  
  485. .twirl
  486.     MoveQ    #20-1,d0
  487. .forBlits1
  488.     Move.l    bitmapSrcPtr(PC),a1
  489.     Move.l    bitmapDestPtr(PC),a2
  490.     Add.l    (a0)+,a1
  491.     Add.l    (a0)+,a2
  492.     MoveM.l    a1/a2,BLTAPTH(a6)
  493.     Move.l    (a0)+,BLTAMOD(a6)
  494.     Move.l    (a0)+,BLTAFWM(a6)
  495.     Move.l    (a0)+,BLTCON0(a6)
  496.     Move.w    (a0)+,BLTSIZE(a6)
  497. .bWait1    Btst    #14,DMACONR(a6)
  498.     Bne.s    .bWait1
  499.     Dbf    d0,.forBlits1
  500.  
  501.     MoveQ    #20-1,d0
  502. .forBlits2
  503.     Move.l    bitmapDestPtr(PC),a1
  504.     Move.l    a1,a2
  505.     Add.l    (a0)+,a1
  506.     Add.l    (a0)+,a2
  507.     MoveM.l    a1/a2,BLTAPTH(a6)
  508.     Move.l    (a0)+,BLTAMOD(a6)
  509.     Move.l    (a0)+,BLTAFWM(a6)
  510.     Move.l    (a0)+,BLTCON0(a6)
  511.     Move.w    (a0)+,BLTSIZE(a6)
  512. .bWait2    Btst    #14,DMACONR(a6)
  513.     Bne.s    .bWait2
  514.     Dbf    d0,.forBlits2
  515.     Rts
  516.  
  517.     ;----------------------------------------------------------------------------------------------
  518.  
  519. blitVals    
  520.     Include    BlitVals.Asm
  521.  
  522.  
  523. ;======================================================================================================
  524.  
  525.  
  526.     CNOP    0,4
  527. font    Incbin    Font12x12x2.Raw
  528.  
  529.     CNOP    0,2
  530. palette    Incbin    Palette.Raw
  531.  
  532.     ;----------------------------------------------------------------------------------------------
  533.  
  534.     Section    ChipStuff,Data_C
  535.  
  536. copList    Dc.w    $2001,$fffe
  537.     Dc.w    DIWSTRT,$2db0
  538.     Dc.w    DIWSTOP,$f391
  539.     Dc.w    DDFSTRT,$0050
  540.     Dc.w    DDFSTOP,$00b8
  541.    
  542.     Dc.w    BPLCON0,$5204
  543.     Dc.w    BPLCON1,$0060
  544.     Dc.w    BPLCON2,$007f
  545.     Dc.w    BPLCON3,$0c00
  546.     Dc.w    BPL1MOD,40*(3-1)+12
  547.     Dc.w    BPL2MOD,28*(2-1)
  548.     
  549. bplPtrs    Dc.w    BPL1PTL,0,BPL1PTH,0,BPL3PTL,0,BPL3PTH,0,BPL5PTL,0,BPL5PTH,0
  550.     Dc.w    BPL2PTL,0,BPL2PTH,0,BPL4PTL,0,BPL4PTH,0
  551.  
  552. colours    Dc.w    COLOR00,0,COLOR01,0,COLOR04,0,COLOR05,0            ;Backgound colours (0..7)
  553.     Dc.w    COLOR16,0,COLOR17,0,COLOR20,0,COLOR21,0
  554.     Dc.w    COLOR10,0,COLOR11,0,COLOR14,0,COLOR15,0            ;Text shadow colour (0..7)
  555.     Dc.w    COLOR26,0,COLOR27,0,COLOR30,0,COLOR31,0
  556.     Dc.w    COLOR02,0,COLOR03,0,COLOR06,0,COLOR07,0            ;Text colour 1 (0..7)
  557.     Dc.w    COLOR18,0,COLOR19,0,COLOR22,0,COLOR23,0
  558.     Dc.w    COLOR08,0,COLOR09,0,COLOR12,0,COLOR13,0            ;Text colour 2 (0..7)
  559.     Dc.w    COLOR24,0,COLOR25,0,COLOR28,0,COLOR29,0
  560.  
  561.     ;These sprites use COLOR29
  562.     Dc.w    SPR6POS,$0057,SPR6CTL,$0001,SPR6DATB,$0000,SPR6DATA,$8000
  563.     Dc.w    SPR7POS,$00c0,SPR7CTL,$0000,SPR7DATB,$0000,SPR7DATA,$0001
  564.  
  565.     Dc.w    COPJMP2,0                        ;Jump to COP2LC
  566.  
  567.     ;----------------------------------------------------------------------------------------------
  568.     
  569. module    Incbin    MOD.Monty(HiScore)
  570.  
  571.     ;----------------------------------------------------------------------------------------------
  572.  
  573.     CNOP    0,2
  574.     Ds.b    40*10*3
  575. bitmap1    Incbin    Pict320x320x3.Raw
  576.     Ds.b    40*10*3
  577.  
  578.     ;----------------------------------------------------------------------------------------------
  579.  
  580.     Section    BSSChipStuff,BSS_C
  581.  
  582.     CNOP    0,2
  583.     Ds.b    40*10*3
  584. bitmap2    Ds.b    40*320*3
  585.     Ds.b    40*10*3
  586.  
  587.     CNOP    0,2
  588. textBitmap
  589.     Ds.b    28*198*2
  590.     
  591.     CNOP    0,4
  592. copCust    Ds.l    4*200+1
  593.  
  594.     ;----------------------------------------------------------------------------------------------
  595.  
  596.     Section    BSSStuff,BSS
  597.  
  598.     CNOP    0,2
  599. currentPalette
  600.     Ds.w    32